﻿<r:RibbonWindow x:Class="TicketServer.MainWindow"
				xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
				xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
				xmlns:a="clr-namespace:TicketServer.Interfaces.Attributes;assembly=TicketServer.Interfaces"
				xmlns:c="clr-namespace:TicketServer.Common;assembly=TicketServer.Common"
				xmlns:ctl="clr-namespace:TicketServer.Controls;assembly=TicketServer.Controls"
				xmlns:eT="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit.Extended"
				xmlns:r="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
				xmlns:sys="clr-namespace:System;assembly=mscorlib"
				xmlns:t="clr-namespace:TicketServer"
				xmlns:tk="clr-namespace:System.Windows.Controls.DataVisualization;assembly=System.Windows.Controls.DataVisualization.Toolkit"
				xmlns:tkc="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
				xmlns:lex="http://wpflocalizeextension.codeplex.com"
				lex:LocalizeDictionary.DesignCulture="en"
				lex:ResxLocalizationProvider.DefaultAssembly="TicketServer"
				lex:ResxLocalizationProvider.DefaultDictionary="Resources"
				Title="Ticket Server"
				Width="950"
				Height="650"
				MinWidth="450"
				MinHeight="600"
				Closing="Window_Closing"
				DataContext="{Binding RelativeSource={RelativeSource Self}}"
				Icon="App.ico"
				Loaded="Window_Loaded"
				WindowStartupLocation="CenterScreen">
	<r:RibbonWindow.Resources>
		<c:PathToFileNameConverter x:Key="pathConverter" />
		<c:TicketToStatusColorConverter x:Key="ticketColorConverter" />
	</r:RibbonWindow.Resources>
	<eT:BusyIndicator x:Name="busyIndicator" BusyContent="{lex:LocText PleaseWait}">
		<Grid>
			<Grid.ColumnDefinitions>
				<ColumnDefinition />
			</Grid.ColumnDefinitions>

			<Grid.RowDefinitions>
				<RowDefinition Height="Auto" />
				<RowDefinition />
				<RowDefinition Height="25" />
			</Grid.RowDefinitions>

			<r:Ribbon x:Name="ribbon"
					  Title="TicketServer"
					  Grid.Row="0"
					  Grid.Column="0">
				<r:Ribbon.ApplicationMenu>
					<r:RibbonApplicationMenu SmallImageSource="Icons\Menu.png">
						<r:RibbonApplicationMenuItem x:Name="buttonNew"
													 Click="buttonNew_Click"
													 Header="{lex:LocText ButtonNew}"
													 ImageSource="Icons\Large\mail_new.png" />
						<r:RibbonApplicationMenuItem x:Name="buttonOpen"
													 Click="buttonOpen_Click"
													 Header="{lex:LocText ButtonOpen}"
													 ImageSource="Icons\Large\fileopen.png" />
						<r:RibbonApplicationSplitMenuItem Click="buttonImport_Click"
														  Header="{lex:LocText RibbonTabImport}"
														  ImageSource="Icons\Large\fileimport.png">
							<r:RibbonApplicationMenuItem Click="buttonImport_Click"
														 Header="{lex:LocText RibbonButtonImportCSV}"
														 ImageSource="Icons\Large\txt.png" />
						</r:RibbonApplicationSplitMenuItem>
						<r:RibbonApplicationMenuItem 
												Click="buttonSettings_Click"
												DockPanel.Dock="Right"
												Header="{lex:LocText RibbonButtonSettings}"
												ImageSource="Icons\Large\Service Manager.png" />
						<r:RibbonApplicationMenuItem 
												Click="buttonExit_Click"
												DockPanel.Dock="Right"
												Header="{lex:LocText RibbonButtonExit}"
												ImageSource="Icons\Large\application-exit-2.png" />
						<r:RibbonApplicationMenu.AuxiliaryPaneContent>
							<ItemsControl x:Name="listRecentFiles">
								<ItemsControl.ItemTemplate>
									<DataTemplate>
										<r:RibbonApplicationMenuItem Click="ribbonApplicationMenuItemRecentFile_Click"
																	 Header="{Binding .,
																					  Converter={StaticResource ResourceKey=pathConverter}}"
																	 ImageSource="Icons\Large\vcard.png"
																	 Tag="{Binding .}"
																	 ToolTip="{Binding .}" />
									</DataTemplate>
								</ItemsControl.ItemTemplate>
							</ItemsControl>
						</r:RibbonApplicationMenu.AuxiliaryPaneContent>
					</r:RibbonApplicationMenu>
				</r:Ribbon.ApplicationMenu>

				<r:RibbonTab Header="{lex:LocText RibbonTabHome}">
					<r:RibbonGroup>
						<r:RibbonButton Click="buttonReset_Click"
										Label="{lex:LocText ButtonReset}"
										LargeImageSource="Icons\Large\reload.png"
										SmallImageSource="Icons\Small\reload.png"
										ToolTipDescription="{lex:LocText ButtonResetTip}" />
						<r:RibbonButton Click="buttonClear_Click"
										Label="{lex:LocText ButtonClear}"
										LargeImageSource="Icons\Large\editdelete.png"
										SmallImageSource="Icons\Small\editdelete.png"
										ToolTipDescription="{lex:LocText ButtonClearTip}" />
					</r:RibbonGroup>
					<r:RibbonGroup x:Name="ribbonGroupStatus" Visibility="Hidden">
						<r:RibbonButton Click="buttonStatusClear_Click"
										Label="{lex:LocText ButtonClearStatus}"
										LargeImageSource="Icons\Large\agt_update-product.png"
										SmallImageSource="Icons\Small\agt_update-product.png" />
					</r:RibbonGroup>
				</r:RibbonTab>
				<r:RibbonTab Header="{lex:LocText RibbonTabImport}">
					<r:RibbonGroup>
						<r:RibbonButton Click="buttonImport_Click"
										Label="{lex:LocText RibbonButtonImportCSV}"
										LargeImageSource="Icons\Large\txt.png"
										SmallImageSource="Icons\Small\applix.png" />
					</r:RibbonGroup>
				</r:RibbonTab>
				<r:RibbonTab ContextualTabGroupHeader="{lex:LocText TabDatabase}" Header="{lex:LocText RibbonTabFilter}">
					<r:RibbonGroup Header="{lex:LocText GroupTicketMode}">
						<r:RibbonRadioButton x:Name="radioButtonModeAll"
											 Checked="radioButtonFilter_Checked"
											 GroupName="TicketMode"
											 IsChecked="True"
											 Label="{lex:LocText TicketModeAll}" />
						<r:RibbonRadioButton x:Name="radioButtonModeOnline"
											 Checked="radioButtonFilter_Checked"
											 GroupName="TicketMode"
											 Label="{lex:LocText TicketModeOnline}" />
						<r:RibbonRadioButton x:Name="radioButtonModeOffline"
											 Checked="radioButtonFilter_Checked"
											 GroupName="TicketMode"
											 Label="{lex:LocText TicketModeOffline}" />
					</r:RibbonGroup>
					<r:RibbonGroup Header="{lex:LocText GroupTicketType}">
						<r:RibbonRadioButton x:Name="radioButtonTypeAll"
											 Checked="radioButtonFilter_Checked"
											 GroupName="TicketType"
											 IsChecked="True"
											 Label="{lex:LocText TicketTypeAll}" />
						<r:RibbonRadioButton x:Name="radioButtonTypeNormal"
											 Checked="radioButtonFilter_Checked"
											 GroupName="TicketType"
											 Label="{lex:LocText TicketTypeNormal}" />
						<r:RibbonRadioButton x:Name="radioButtonTypeFree"
											 Checked="radioButtonFilter_Checked"
											 GroupName="TicketType"
											 Label="{lex:LocText TicketTypeFree}" />
						<r:RibbonRadioButton x:Name="radioButtonTypeSpecial"
											 Checked="radioButtonFilter_Checked"
											 GroupName="TicketType"
											 Label="{lex:LocText TicketTypeSpecial}" />
					</r:RibbonGroup>
					<r:RibbonGroup Header="{lex:LocText GroupTicketRedeemed}">
						<r:RibbonRadioButton x:Name="radioButtonRedeemedAll"
											 Checked="radioButtonFilter_Checked"
											 GroupName="TicketRedeemed"
											 IsChecked="True"
											 Label="{lex:LocText TicketRedeemedAll}" />
						<r:RibbonRadioButton x:Name="radioButtonRedeemedYes"
											 Checked="radioButtonFilter_Checked"
											 GroupName="TicketRedeemed"
											 Label="{lex:LocText TicketRedeemedYes}" />
						<r:RibbonRadioButton x:Name="radioButtonRedeemedNo"
											 Checked="radioButtonFilter_Checked"
											 GroupName="TicketRedeemed"
											 Label="{lex:LocText TicketRedeemedNo}" />
					</r:RibbonGroup>
				</r:RibbonTab>
				<r:RibbonTab Header="{lex:LocText RibbonTabSettings}">
					<r:RibbonGroup Header="{lex:LocText RibbonGroupLanguage}">
						<r:RibbonMenuButton x:Name="ribbonComboBoxLanguage"
											Width="150"
											Label="{lex:LocText RibbonGroupLanguage}">
							<r:RibbonGallery x:Name="ribbonGalleryLanguages"
											 Width="150"
											 MaxColumnCount="1"
											 SelectedValuePath="Content">
								<r:RibbonGalleryCategory x:Name="ribbonGalleryCategoryLanguages" />
							</r:RibbonGallery>
						</r:RibbonMenuButton>
					</r:RibbonGroup>
				</r:RibbonTab>

				<r:Ribbon.ContextualTabGroups>
					<r:RibbonContextualTabGroup x:Name="tabGroupDatabase"
												Background="BlueViolet"
												Header="{lex:LocText TabDatabase}"
												Visibility="Hidden" />
				</r:Ribbon.ContextualTabGroups>
			</r:Ribbon>

			<TabControl x:Name="tabControlMain"
						Grid.Row="1"
						Grid.Column="0"
						SelectionChanged="tabControlMain_SelectionChanged"
						TabStripPlacement="Bottom">
				<TabItem x:Name="tabStatus" Header="{lex:LocText TabStatus}">
					<ListBox x:Name="listBoxStatus"
							 MouseDoubleClick="listBoxStatus_MouseDoubleClick"
							 ScrollViewer.CanContentScroll="False">
						<ListBox.ItemTemplate>
							<DataTemplate>
								<StackPanel>
									<StackPanel Orientation="Horizontal">
										<TextBlock Text="{lex:LocText StatusClient}" />
										<TextBlock Margin="5 0 5 0" Text="{Binding Client}" />
										<TextBlock Text="{lex:LocText StatusTime}" />
										<TextBlock Margin="5 0 5 0" Text="{Binding Created, StringFormat='{}{0:hh:mm:ss}'}" />
									</StackPanel>
									<ctl:TicketStatus x:Name="statusControl"
													  Margin="5"
													  DataContext="{Binding .}"
													  Ticket="{Binding Ticket, ElementName=., Mode=OneWay}">
										<ctl:TicketStatus.Background>
											<MultiBinding Converter="{StaticResource ResourceKey=ticketColorConverter}">
												<Binding Path="Ticket" />
												<Binding Path="Result" />
											</MultiBinding>
										</ctl:TicketStatus.Background>
									</ctl:TicketStatus>
								</StackPanel>
							</DataTemplate>
						</ListBox.ItemTemplate>
					</ListBox>
				</TabItem>
				<TabItem x:Name="tabDatabase" Header="{lex:LocText TabDatabase}">
					<t:DatabaseControl x:Name="databaseControlMain" />
				</TabItem>
				<TabItem x:Name="tabStatistic" Header="{lex:LocText TabStatistic}">
					<Grid>
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="100" />
							<ColumnDefinition Width="150" />
							<ColumnDefinition />
						</Grid.ColumnDefinitions>
						<Grid.RowDefinitions>
							<RowDefinition Height="*" />
							<RowDefinition Height="34" />
						</Grid.RowDefinitions>

						<tkc:Chart x:Name="chartStatistic"
								   Title="{lex:LocText ChartStatisticTitle}"
								   Grid.Row="0"
								   Grid.Column="0"
								   Grid.ColumnSpan="3">
							<tkc:LineSeries x:Name="lineSeriesStatisticTotal" Title="{lex:LocText ChartStatisticSeriesTotal}" />
							<tkc:AreaSeries x:Name="areaSeriesStatisticPerUnit" Title="{lex:LocText ChartStatisticSeriesPerUnit}" />
						</tkc:Chart>

						<TextBlock Grid.Row="1"
								   Grid.Column="0"
								   HorizontalAlignment="Right"
								   VerticalAlignment="Center"
								   Text="{lex:LocText comboBoxResolution}" />
						<ComboBox x:Name="comboBoxStatisticResolution"
								  Grid.Row="1"
								  Grid.Column="1"
								  Margin="5"
								  SelectionChanged="comboBoxStatisticResolution_SelectionChanged">
							<ComboBoxItem Content="{lex:LocText Resolution5Minutes}" Tag="5" />
							<ComboBoxItem Content="{lex:LocText Resolution15Minutes}" Tag="15" />
							<ComboBoxItem Content="{lex:LocText Resolution30Minutes}" Tag="30" />
							<ComboBoxItem Content="{lex:LocText Resolution60Minutes}"
										  IsSelected="True"
										  Tag="60" />
						</ComboBox>
					</Grid>
				</TabItem>
			</TabControl>

			<StatusBar Grid.Row="2"
					   Grid.Column="0"
					   Margin="0 2 0 0"
					   BorderBrush="Gray"
					   BorderThickness="0 1 0 0">
				<StatusBar.ItemsPanel>
					<ItemsPanelTemplate>
						<Grid Margin="0">
							<Grid.RowDefinitions>
								<RowDefinition Height="*" />
							</Grid.RowDefinitions>
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="*" />
								<ColumnDefinition Width="Auto" />
								<ColumnDefinition Width="Auto" />
								<ColumnDefinition Width="Auto" />
								<ColumnDefinition Width="Auto" />
								<ColumnDefinition Width="Auto" />
							</Grid.ColumnDefinitions>
						</Grid>
					</ItemsPanelTemplate>
				</StatusBar.ItemsPanel>

				<StatusBarItem>
					<TextBlock x:Name="statusBarItemInfo"
							   Width="Auto"
							   Margin="5 0 5 0"
							   Text="{lex:LocText MainStatusLoading}" />
				</StatusBarItem>
				<StatusBarItem Grid.Column="1">
					<TextBlock x:Name="statusBarItemTickets" Text="{lex:LocText MainStatusTickets}" />
				</StatusBarItem>
				<StatusBarItem Grid.Column="2">
					<TextBlock x:Name="statusBarItemTicketsRedeemed"
							   FontWeight="Bold"
							   Text="{Binding Service.TicketSource.RedeemedCount}" />
				</StatusBarItem>
				<StatusBarItem Grid.Column="3">
					<TextBlock x:Name="statusBarItemTicketsSeparator"
							   FontWeight="Bold"
							   Text="/" />
				</StatusBarItem>
				<StatusBarItem Grid.Column="4">
					<TextBlock x:Name="statusBarItemTicketsTotal"
							   FontWeight="Bold"
							   Text="{Binding Service.TicketSource.TicketCount}" />
				</StatusBarItem>
			</StatusBar>
		</Grid>
	</eT:BusyIndicator>
</r:RibbonWindow>
